class Solution {
public:
    string to_binary(int n) {
        string str;
        do {
            str.push_back(n % 2 + '0');
            n /= 2;
        } while (n);
        return str;
    }
    vector<int> evenOddBit(int n) {
        string s = to_binary(n);
        int even = 0, odd = 0;
        for (int i = 0; i < s.size(); i++) {
            if (i & 1) {
                odd += (s[i] == '1');
            } else {
                even += (s[i] == '1');
            }
        }
        vector<int> res = {even, odd};
        return res;
    }
};
